package com.tiger.communal.service.impl;

import java.util.List;

import com.tiger.communal.domain.HydropowerSubmeterAlter;
import com.tiger.communal.mapper.HydropowerSubmeterAlterMapper;
import com.tiger.communal.service.IHydropowerSubmeterAlterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 水电分历史Service业务层处理
 *
 * @author standard
 * @date 2022-10-14
 */
@Service
public class HydropowerSubmeterAlterServiceImpl implements IHydropowerSubmeterAlterService {
    @Autowired
    private HydropowerSubmeterAlterMapper hydropowerSubmeterAlterMapper;

    /**
     * 查询水电分历史
     *
     * @param id 水电分历史主键
     * @return 水电分历史
     */
    @Override
    public HydropowerSubmeterAlter selectHydropowerSubmeterAlterById(Long id) {
        return hydropowerSubmeterAlterMapper.selectHydropowerSubmeterAlterById(id);
    }

    /**
     * 查询水电分历史列表
     *
     * @param hydropowerSubmeterAlter 水电分历史
     * @return 水电分历史
     */
    @Override
    public List<HydropowerSubmeterAlter> selectHydropowerSubmeterAlterList(HydropowerSubmeterAlter hydropowerSubmeterAlter) {
        return hydropowerSubmeterAlterMapper.selectHydropowerSubmeterAlterList(hydropowerSubmeterAlter);
    }

    /**
     * 新增水电分历史
     *
     * @param hydropowerSubmeterAlter 水电分历史
     * @return 结果
     */
    @Override
    public int insertHydropowerSubmeterAlter(HydropowerSubmeterAlter hydropowerSubmeterAlter) {
        HydropowerSubmeterAlter alter = hydropowerSubmeterAlterMapper.selectNum(hydropowerSubmeterAlter.getHydropowerSubmeterId());
        if (alter != null){
            hydropowerSubmeterAlter.setNum(alter.getNum() + 1);
        }
        return hydropowerSubmeterAlterMapper.insertHydropowerSubmeterAlter(hydropowerSubmeterAlter);
    }

    /**
     * 修改水电分历史
     *
     * @param hydropowerSubmeterAlter 水电分历史
     * @return 结果
     */
    @Override
    public int updateHydropowerSubmeterAlter(HydropowerSubmeterAlter hydropowerSubmeterAlter) {
        return hydropowerSubmeterAlterMapper.updateHydropowerSubmeterAlter(hydropowerSubmeterAlter);
    }

    /**
     * 批量删除水电分历史
     *
     * @param ids 需要删除的水电分历史主键
     * @return 结果
     */
    @Override
    public int deleteHydropowerSubmeterAlterByIds(Long[] ids) {
        return hydropowerSubmeterAlterMapper.deleteHydropowerSubmeterAlterByIds(ids);
    }

    /**
     * 删除水电分历史信息
     *
     * @param id 水电分历史主键
     * @return 结果
     */
    @Override
    public int deleteHydropowerSubmeterAlterById(Long id) {
        return hydropowerSubmeterAlterMapper.deleteHydropowerSubmeterAlterById(id);
    }
}
